﻿#ifndef SIGNUPLOGIN_H
#define SIGNUPLOGIN_H

#include <QWidget>
#include <QTcpSocket>
#include <QMouseEvent>
//#include <QPainter>
#include "mainface.h"

namespace Ui {
class SignUpLogin;
}

class SignUpLogin : public QWidget
{
    Q_OBJECT

public:
    explicit SignUpLogin(QWidget *parent = nullptr);
    ~SignUpLogin();

    // 发送到服务器
    void WriteToServer(const QJsonObject &obj);

    // 处理json逻辑
    void process(const QByteArray &data);

    // 设置头像
    void SetPhoto(const QPixmap &photo);

protected:
    void mousePressEvent(QMouseEvent *e);

//    void paintEvent(QPaintEvent *event)
//    {
//        QPainter painter(this);
//        QPixmap background(":/img/background.jpg");
//        painter.drawPixmap(0, 0, width(), height(), background);
//        QWidget::paintEvent(event);
//    }

signals:
    void SetSocketAndName(QTcpSocket *socket, const QString &fromname);

private slots:
    void on_pushButton_signup_clicked();

    void on_pushButton_login_clicked();

    void ReadData();

private:
    Ui::SignUpLogin *ui;
    QTcpSocket *socket;
    QByteArray buffer; // 自定义缓冲区
    MainFace *face;
};

#endif // SIGNUPLOGIN_H
